package com.gjun.struts.action;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.gjun.struts.bean.GjunsystemPrivilege;
import com.gjun.struts.resource.GjunPrivilegeResourceIf;
import com.gjun.struts.resource.GjunSystemUserResourceIf;

public class ReloadPrivilegeAction {

	private GjunPrivilegeResourceIf privilegeDAO;

	private GjunSystemUserResourceIf systemUserDAO;
	
	private String result;
	
	

	public String getResult() {
		return result;
	}



	public void setResult(String result) {
		this.result = result;
	}



	public GjunPrivilegeResourceIf getPrivilegeDAO() {
		return privilegeDAO;
	}



	public void setPrivilegeDAO(GjunPrivilegeResourceIf privilegeDAO) {
		this.privilegeDAO = privilegeDAO;
	}



	public GjunSystemUserResourceIf getSystemUserDAO() {
		return systemUserDAO;
	}



	public void setSystemUserDAO(GjunSystemUserResourceIf systemUserDAO) {
		this.systemUserDAO = systemUserDAO;
	}



	public String execute() {
		
		HttpSession session = ServletActionContext.getRequest().getSession();
		
		
		List<GjunsystemPrivilege> allPris = privilegeDAO.loadAllPrivilege();
	    session.setAttribute("allPris",allPris);
	    
	    List<GjunsystemPrivilege> accountPris = systemUserDAO.loadUserPrivilegesByUserId((Integer)session.getAttribute("accountId"));
	    session.setAttribute("accountPris",accountPris);
	    result = "success";
		return "success";
	}
}
